/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package airacrobats.gui.component;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Timer;

/**
 * This label is an ALabel that flashes.
 */
public class ATimerLabel extends ALabel
{
    /**
     * The timer.
     */
    private Timer timer;
    /**
     * Visible flag.
     */
    private boolean visible;

    /**
     * @param text Text.
     * @param color Color.
     * @param outlineColor Outline color.
     * @param interval Flashing interval.
     */
    public ATimerLabel(String text, Color color, Color outlineColor, int interval)
    {
        super(text, color, outlineColor);
        visible = true;

        timer = new Timer(interval, new ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {
                visible = !visible;
                repaint();
            }
        });

        timer.start();
    }

    /**
     * Stops the label timer.
     */
    public void stop()
    {
        timer.stop();
    }

    /**
     */
    @Override
    protected void paintComponent(Graphics g)
    {
        if (visible)
            super.paintComponent(g);
    }
}
